import { ref } from 'vue'
import { useMapStore } from '@/stores/map.js'
import { storeToRefs } from 'pinia'
// 引入点查询de中地接口
import { Point } from '@/Utils/Point.js'
import { useDialogEvents } from '@/stores/dialogEvents.js'
import { useDialog } from '@/stores/dialogSwitch.js'

const { map } = storeToRefs(useMapStore())

// 定义获取点击后的添加事件的位置
const { addEventPosition } = storeToRefs(useDialogEvents())
// 事件添加popup控制开关
const { addEventDialogVisible, changeEventDialogVisible } = storeToRefs(useDialog())
export const addEvent = () => {
  // 把同时对地图操作的事件更新关掉

  var add = map.value.once('click', (e) => {
    // 打开事件添加的弹窗
    addEventDialogVisible.value = true
    //点击map获取坐标
    addEventPosition.value = e.coordinate
  })
}
